#include<iostream>
using namespace std;

class Person
{
public:
	int* m_Age;
	
	Person(int age)
	{
		m_Age = new int(age);
	}
	~Person()
	{
		if (m_Age)
		{
			delete m_Age;
			m_Age = NULL;
		}
	}
	Person& operator=(Person& p)
	{
		if (m_Age)
			delete m_Age;
		m_Age = new int(*p.m_Age);
		return *this;
	}
};

int main()
{
	Person p1(18);
	cout << "p1age:" << *p1.m_Age << endl;
	Person p2(10);
	Person p3(30);
	cout << "p2age:" << *p2.m_Age << endl;
	cout << "p3age:" << *p3.m_Age << endl;
	p3 = p2 = p1;
	cout << "p2age:" << *p2.m_Age << endl;
	cout << "p3age:" << *p3.m_Age << endl; 
	return 0;
}
